package com.pic.mgt.action;

public class AutoInspectMissUnitActionImpl implements AutoInspectMissUnitAction {
	
	private MissUnitInspectAction missBusinessUnitInspectAction;
	private MissUnitInspectAction missMessageUnitInspectAction;

	@Override
	public synchronized boolean autoInspectMissUnitAndRecover() {
		boolean isAutoRecoveryBusinessSuccessful;
		boolean isAutoRecoveryMessageSuccessful;
		
		// (1) 自動檢測 Business 並恢復
		isAutoRecoveryBusinessSuccessful =
			this.missBusinessUnitInspectAction.inspectMissUnitAndRecover();
		
		// (2) 自動檢測 Message 並恢復
		isAutoRecoveryMessageSuccessful = 
			this.missMessageUnitInspectAction.inspectMissUnitAndRecover();
		
		if (isAutoRecoveryBusinessSuccessful && isAutoRecoveryMessageSuccessful) {
			return true;
		}
		else {
			return false;
		}
	}
	
	// --- getter and setter ---

	public void setMissBusinessUnitInspectAction(
			MissUnitInspectAction missBusinessUnitInspectAction) {
		this.missBusinessUnitInspectAction = missBusinessUnitInspectAction;
	}

	public void setMissMessageUnitInspectAction(
			MissUnitInspectAction missMessageUnitInspectAction) {
		this.missMessageUnitInspectAction = missMessageUnitInspectAction;
	}

}
